/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

import Client.Customer;
import constant.ERROR;
import java.util.ArrayList;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author konsta
 */
@Stateless
public class ClientFacade extends AbstractFacade<Client> {

    @PersistenceContext(unitName = "team_project-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ClientFacade() {
        super(Client.class);
    }

    public Client get_ClientInfo(String id) {

        ArrayList<Client> result = new ArrayList<>();
        /* for (Client c : findAll()) {
         if () {
         return c;
         }
            
         }*/
        return null;
    }
    
    public void save(Client c){
        
        this.create(c);
        
    }

    public int check_login(String Insurance_id, String password) {

        if (Insurance_id == Insurance_id) {

        }
        return ERROR.NO_ERROR;
    }

    public int sign_up(Client cus) {

        //+ check ERROR
        ArrayList<Client> result = new ArrayList<>();
        for (Client c : findAll()) {

          //  c.setInsurunce_Id(cus.getInsurunce_Id());
        }
        return ERROR.NO_ERROR;
    }
    /*
     public String private_by_Client(String id) {

     String str = null;
     ArrayList<String> temp;
     for (Customer c : findAll()) {
     if (c. == id) {
     str = Integer.toString(c.getInsurancetype());
     return str;
     }
     }
        
     return null;
     }
     */

    public int set_facebook_login(String facebook_ID, String facebook_PW) {
        //store clients' id and pw
        if (facebook_ID == null || facebook_PW == null) {
            return ERROR.NULL_ERROR;
        }

        return ERROR.NO_ERROR;
    }

public  ArrayList<Client> findall_by_db (){

 ArrayList<Client> result = new ArrayList<>();

        for (Client c : findAll()) {
                result.add(c);
            }
        
        return result;

}

 
}